package com.daocao.hua.api.requestInfo;

import com.daocao.hua.api.Api;
import com.daocao.hua.api.bean.ResetPwdNewBean;
import com.daocao.hua.api.callback.UpdatePwdContract;
import com.daocao.hua.util.Network;
import com.daocao.hua.util.RxLifeUtil;
import com.daocao.hua.util.ToastUtil;

/**
 * Created by Administrator on 2017/5/14.
 */

public class UpdatePwdRequest extends BaseRequest<UpdatePwdContract.View> implements UpdatePwdContract.Presenter<UpdatePwdContract.View> {

    public static UpdatePwdRequest create() {
        return new UpdatePwdRequest();
    }



    @Override
    public void getCheckPwdInfo(String password) {
        if (!Network.checkNetwork(BaseContext)) {
            ToastUtil.makeText(BaseContext, networkFail).show();
            return;
        }
        mView.onRequestStart();
        ResetPwdNewBean bean = new ResetPwdNewBean();
        bean.password = password;
        Api.api_service.getCheckPwdInfo(bean).compose(RxLifeUtil.checkOn(BaseContext)).
                doFinally(() -> {
                    try {
                        mView.complete();

                    } catch (NullPointerException e) {

                    }
                }).
                subscribe(result -> {
                    mView.getCheckPwdInfoSuccess(result);
                });
    }

}
